var files = {
	"./code/vite.config.js":`
	import { defineConfig } from 'vite' // 动态配置函数
import { createVuePlugin } from 'vite-plugin-vue2'
import { resolve } from 'path'

export default () =>
	defineConfig({
		plugins: [createVuePlugin()],
		server: {
			open: true, //自动打开浏览器
			port: 1567 //端口号
		},
		resolve: {
            // 别名
			alias: [
				{
					find: '@',
					replacement: '/src'
				}
			]
		}
	})


	`,
	"./code/package.json":`
	{
  "name": "vite-project",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "element-ui": "^2.15.13",
    "vue": "^2.7.14",
    "vue-template-compiler": "^2.7.14"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.2.0",
    "vite": "^2.8.0",
    "vite-plugin-vue2": "^1.9.3"
  }
}

	`,
	"./code/index.html":`<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite App</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.js"></script>
  </body>
</html>
`,
	"./code/src/App.vue":`
	

<template>
    <div> 
	  <el-button type="primary">主要按钮</el-button>
	  <el-button type="success">成功按钮</el-button> 
    </div>
</template> 
	`,
	"./code/src/main.js":`import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';

Vue.use(ElementUI);

new Vue({
	render: h => h(App)
}).$mount('#app')
`,
"./code/src/components/HelloWorld.vue":``,   
}

var list= Object.keys(files) 
const fs = require("fs");
const path = require('path');
list.map(e => { 
  try {
    fs.mkdirSync(e.substring(0, e.lastIndexOf("/")), {
      recursive: true
    });
  } catch (error) {}
   fs.writeFile(e, files[e], err => {
    if (err) {
      console.error(err);
      return;
    }   
  });
});